/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.edu.fatec.ads.classes;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Transient;

/**
 *
 * @author Bruno Moura
 */
@Entity
public class Departamento extends AbstractTO{

    private int codigo;
    private String descricao;

    public Departamento() {
    }

    /**
     * @return the codigo
     */
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="cd_departamento", length=4)
    public int getCodigo() {
        return codigo;
    }

    /**
     * @param codigo the codigo to set
     */
    public void setCodigo(int codigo) {
        this.codigo = codigo;
    }

    /**
     * @return the descricao
     */
    @Column(name="ds_departamento", length=20, nullable=false)
    public String getDescricao() {
        return descricao;
    }

    /**
     * @param descricao the descricao to set
     */
    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    @Override
    @Transient
    public Serializable getPK() {
        return this.getCodigo();
    }

    @Override
    public void setPK(Serializable identifier) {
        this.setCodigo((Integer) identifier);
    }

    @Override
    public String toString() {
        return "Departamento[codigo=" + this.getCodigo()
                + ", descricao=" + this.getDescricao() + "]";
    }

}
